package com.ruoyi.faceplus.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.faceplus.domain.FaceRecognition;
import com.ruoyi.faceplus.service.IFaceRecognitionService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 人脸识别库Controller
 * 
 * @author ruoyi
 * @date 2025-01-17
 */
@RestController
@RequestMapping("/faceplus/facerecognition")
public class FaceRecognitionController extends BaseController
{
    @Autowired
    private IFaceRecognitionService faceRecognitionService;

    /**
     * 查询人脸识别库列表
     */
    @PreAuthorize("@ss.hasPermi('faceplus:facerecognition:list')")
    @GetMapping("/list")
    public TableDataInfo list(FaceRecognition faceRecognition)
    {
        startPage();
        List<FaceRecognition> list = faceRecognitionService.selectFaceRecognitionList(faceRecognition);
        return getDataTable(list);
    }

    /**
     * 导出人脸识别库列表
     */
    @PreAuthorize("@ss.hasPermi('faceplus:facerecognition:export')")
    @Log(title = "人脸识别库", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FaceRecognition faceRecognition)
    {
        List<FaceRecognition> list = faceRecognitionService.selectFaceRecognitionList(faceRecognition);
        ExcelUtil<FaceRecognition> util = new ExcelUtil<FaceRecognition>(FaceRecognition.class);
        util.exportExcel(response, list, "人脸识别库数据");
    }

    /**
     * 获取人脸识别库详细信息
     */
    @PreAuthorize("@ss.hasPermi('faceplus:facerecognition:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(faceRecognitionService.selectFaceRecognitionById(id));
    }

    /**
     * 新增人脸识别库
     */
    @PreAuthorize("@ss.hasPermi('faceplus:facerecognition:add')")
    @Log(title = "人脸识别库", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FaceRecognition faceRecognition)
    {
        return toAjax(faceRecognitionService.insertFaceRecognition(faceRecognition));
    }

    /**
     * 修改人脸识别库
     */
    @PreAuthorize("@ss.hasPermi('faceplus:facerecognition:edit')")
    @Log(title = "人脸识别库", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FaceRecognition faceRecognition)
    {
        return toAjax(faceRecognitionService.updateFaceRecognition(faceRecognition));
    }

    /**
     * 删除人脸识别库
     */
    @PreAuthorize("@ss.hasPermi('faceplus:facerecognition:remove')")
    @Log(title = "人脸识别库", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(faceRecognitionService.deleteFaceRecognitionByIds(ids));
    }
}
